package com.qidian.mespro.controller;

import com.github.pagehelper.PageInfo;
import com.qidian.mespro.service.ProcessService;
import com.qidianit.mes.pojo.Process;
import com.qidianit.mes.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ author: 周晓轩
 * @ company 起点编程
 * @ time: 2025/9/17 - 16:17
 * @ Description:
 */
@RestController
@RequestMapping("/process")
public class ProcessController {

    @Autowired
    private ProcessService processService;

    @GetMapping("page")
    public Result<PageInfo<com.qidianit.mes.pojo.Process>> list(Process process, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10")int size){
        return processService.ProcessList(process,page,size);
    };

    @PostMapping("/add")
    public Result<Process> save(@RequestBody Process process){
        return processService.addProcess(process);
    };

    @GetMapping("/code/{code}")
    public Result<Process> getByCode(@PathVariable("code") String code){
        return processService.selectProcessByCode(code);
    }

    @PutMapping("/update")
    public Result update(@RequestBody Process process){
        return processService.updateProcessById(process);
    };

    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Long id){
        return processService.deleteProcessById(id);
    }

    @DeleteMapping("/batchDelete")
    public Result batchDelete(Long [] id){
        return processService.batchDelete(id);
    };
}
